<template>
	<view>
		<u-popup mode="center" :safeAreaInsetBottom="false" round="12" :show="show" :closeOnClickOverlay="true"
			@close="handleClose">
			<view class="notice-wrapper">
				<image class="notice-wrapper_bg" src="/static/img/modal_bg.png" mode="widthFix"></image>
				<view class="notice-title" v-if="title">{{ title }}</view>
				<view class="notice-content">
					<slot>
						<rich-text :nodes="content"></rich-text>
					</slot>
				</view>
				<view class="notice-wrapper_ft">
					<view class="notice-btn" @click.stop="handleCancel" v-if="showCancelButton">{{ cancelText }}</view>
					<view class="notice-btn primary" @click.stop="handleConfirm" v-if="showConfirmButton">
						{{ confirmText }}
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		name: 'noticeModal',
		props: {
			show: {
				type: Boolean,
				default: false
			},
			title: {
				type: [String],
			},
			content: {
				type: String
			},
			// 确认文案
			confirmText: {
				type: String,
				default: '确认'
			},
			// 取消文案
			cancelText: {
				type: String,
				default: '取消'
			},
			// 是否显示确认按钮
			showConfirmButton: {
				type: Boolean,
				default: true
			},
			// 是否显示取消按钮
			showCancelButton: {
				type: Boolean,
				default: false
			},
		},
		data() {
			return {

			}
		},
		methods: {
			handleClose() {
				this.$emit('close')
			},
			handleCancel() {
				this.$emit('cancel')
			},
			handleConfirm() {
				this.$emit('confirm')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.notice-wrapper {
		width: 640rpx;
		box-sizing: border-box;
		padding: 48rpx;
		position: relative;
		z-index: 10;
		color: #333;

		&_bg {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			z-index: -1;
		}

		.notice-title {
			font-size: 36rpx;
			font-weight: bold;
			margin-bottom: 24rpx;
		}

		.notice-content {
			font-size: 28rpx;
		}

		.notice-wrapper_ft {
			display: flex;

			.notice-btn {
				flex: 1;
				font-size: 28rpx;
				font-weight: bold;
				line-height: 88rpx;
				text-align: center;
				border-radius: 24rpx;
				border: 1rpx solid #FFDA2D;
				margin-top: 32rpx;

				&+.notice-btn {
					margin-left: 16rpx;
				}

				&.primary {
					background-color: #FFDA2D;
				}
			}
		}
	}
</style>
